/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 15-10-15
 * Time: 上午4:30
 * To change this template use File | Settings | File Templates.
 */

function bindEvent(){
    $(".m_chcshow>i").click(function(){
        $(this).next(".m_chc").slideToggle();
    });
}
window.onload=function(){
    var url = getUrl();
    var userId=getUserId();
    $.jsonp({
        url: 'http://'+url+'/api/photobook/photobook_list',
        data: {userId:userId},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            var complied_tpl = juicer($("#cjhc_tpl").text());
            var html = complied_tpl.render(data);
            $(".wrapper").append(html);
            bindEvent();
        },
        error: function (xOptions, textStatus) {
        }
    });


    $(document).on("click",".icons-delete",function(){
        var id = $(this).attr("id");
        $.jsonp({
            url: 'http://'+url+'/api/photobook/delete?photoBookId='+id,
            data: {userId:userId},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                location.reload();
            },
            error: function (xOptions, textStatus) {
            }
        });
    });

}
